{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": "          A         B         C         D\n0 -2.453970  0.564621  0.670272 -0.345173\n1 -0.124559  0.081625  0.382049 -0.449489\n2 -1.367770  0.362711 -0.085119  0.110784\n3 -1.535637 -0.109173  2.317123 -0.879901\n4 -1.007252  0.142094 -1.143808  0.918524\n5 -0.552521  1.484423  1.436369  0.382054\n6 -0.216479  1.238049  0.705584 -1.218741\n7 -1.782425 -0.117057  0.323656 -0.032317\n8 -0.005736  0.664067 -1.027564  1.295308\n9  0.428075 -1.257755 -0.884078  0.248043",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>A</th>\n      <th>B</th>\n      <th>C</th>\n      <th>D</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>-2.453970</td>\n      <td>0.564621</td>\n      <td>0.670272</td>\n      <td>-0.345173</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>-0.124559</td>\n      <td>0.081625</td>\n      <td>0.382049</td>\n      <td>-0.449489</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>-1.367770</td>\n      <td>0.362711</td>\n      <td>-0.085119</td>\n      <td>0.110784</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>-1.535637</td>\n      <td>-0.109173</td>\n      <td>2.317123</td>\n      <td>-0.879901</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>-1.007252</td>\n      <td>0.142094</td>\n      <td>-1.143808</td>\n      <td>0.918524</td>\n    </tr>\n    <tr>\n      <th>5</th>\n      <td>-0.552521</td>\n      <td>1.484423</td>\n      <td>1.436369</td>\n      <td>0.382054</td>\n    </tr>\n    <tr>\n      <th>6</th>\n      <td>-0.216479</td>\n      <td>1.238049</td>\n      <td>0.705584</td>\n      <td>-1.218741</td>\n    </tr>\n    <tr>\n      <th>7</th>\n      <td>-1.782425</td>\n      <td>-0.117057</td>\n      <td>0.323656</td>\n      <td>-0.032317</td>\n    </tr>\n    <tr>\n      <th>8</th>\n      <td>-0.005736</td>\n      <td>0.664067</td>\n      <td>-1.027564</td>\n      <td>1.295308</td>\n    </tr>\n    <tr>\n      <th>9</th>\n      <td>0.428075</td>\n      <td>-1.257755</td>\n      <td>-0.884078</td>\n      <td>0.248043</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "## @File : pandas_style.ipynb\n",
    "# @Author : SeafyLiang\n",
    "# @Date : 2021/6/18 17:05\n",
    "# @Description : pandas美化表格(样式修改)\n",
    "\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "\n",
    "# 生成测试数据\n",
    "data = pd.DataFrame(np.random.randn(10, 4), columns=list('ABCD'))\n",
    "data"
   ]
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 1. 高亮\n",
    "- 对指定列最大值高亮处理\n",
    "- 对指定条件的元素修改颜色"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "outputs": [
    {
     "data": {
      "text/plain": "<pandas.io.formats.style.Styler at 0x139c516a0>",
      "text/html": "<style  type=\"text/css\" >\n#T_11089_row3_col2,#T_11089_row5_col1,#T_11089_row8_col3,#T_11089_row9_col0{\n            background-color:  yellow;\n        }</style><table id=\"T_11089_\" ><thead>    <tr>        <th class=\"blank level0\" ></th>        <th class=\"col_heading level0 col0\" >A</th>        <th class=\"col_heading level0 col1\" >B</th>        <th class=\"col_heading level0 col2\" >C</th>        <th class=\"col_heading level0 col3\" >D</th>    </tr></thead><tbody>\n                <tr>\n                        <th id=\"T_11089_level0_row0\" class=\"row_heading level0 row0\" >0</th>\n                        <td id=\"T_11089_row0_col0\" class=\"data row0 col0\" >-2.453970</td>\n                        <td id=\"T_11089_row0_col1\" class=\"data row0 col1\" >0.564621</td>\n                        <td id=\"T_11089_row0_col2\" class=\"data row0 col2\" >0.670272</td>\n                        <td id=\"T_11089_row0_col3\" class=\"data row0 col3\" >-0.345173</td>\n            </tr>\n            <tr>\n                        <th id=\"T_11089_level0_row1\" class=\"row_heading level0 row1\" >1</th>\n                        <td id=\"T_11089_row1_col0\" class=\"data row1 col0\" >-0.124559</td>\n                        <td id=\"T_11089_row1_col1\" class=\"data row1 col1\" >0.081625</td>\n                        <td id=\"T_11089_row1_col2\" class=\"data row1 col2\" >0.382049</td>\n                        <td id=\"T_11089_row1_col3\" class=\"data row1 col3\" >-0.449489</td>\n            </tr>\n            <tr>\n                        <th id=\"T_11089_level0_row2\" class=\"row_heading level0 row2\" >2</th>\n                        <td id=\"T_11089_row2_col0\" class=\"data row2 col0\" >-1.367770</td>\n                        <td id=\"T_11089_row2_col1\" class=\"data row2 col1\" >0.362711</td>\n                        <td id=\"T_11089_row2_col2\" class=\"data row2 col2\" >-0.085119</td>\n                        <td id=\"T_11089_row2_col3\" class=\"data row2 col3\" >0.110784</td>\n            </tr>\n            <tr>\n                        <th id=\"T_11089_level0_row3\" class=\"row_heading level0 row3\" >3</th>\n                        <td id=\"T_11089_row3_col0\" class=\"data row3 col0\" >-1.535637</td>\n                        <td id=\"T_11089_row3_col1\" class=\"data row3 col1\" >-0.109173</td>\n                        <td id=\"T_11089_row3_col2\" class=\"data row3 col2\" >2.317123</td>\n                        <td id=\"T_11089_row3_col3\" class=\"data row3 col3\" >-0.879901</td>\n            </tr>\n            <tr>\n                        <th id=\"T_11089_level0_row4\" class=\"row_heading level0 row4\" >4</th>\n                        <td id=\"T_11089_row4_col0\" class=\"data row4 col0\" >-1.007252</td>\n                        <td id=\"T_11089_row4_col1\" class=\"data row4 col1\" >0.142094</td>\n                        <td id=\"T_11089_row4_col2\" class=\"data row4 col2\" >-1.143808</td>\n                        <td id=\"T_11089_row4_col3\" class=\"data row4 col3\" >0.918524</td>\n            </tr>\n            <tr>\n                        <th id=\"T_11089_level0_row5\" class=\"row_heading level0 row5\" >5</th>\n                        <td id=\"T_11089_row5_col0\" class=\"data row5 col0\" >-0.552521</td>\n                        <td id=\"T_11089_row5_col1\" class=\"data row5 col1\" >1.484423</td>\n                        <td id=\"T_11089_row5_col2\" class=\"data row5 col2\" >1.436369</td>\n                        <td id=\"T_11089_row5_col3\" class=\"data row5 col3\" >0.382054</td>\n            </tr>\n            <tr>\n                        <th id=\"T_11089_level0_row6\" class=\"row_heading level0 row6\" >6</th>\n                        <td id=\"T_11089_row6_col0\" class=\"data row6 col0\" >-0.216479</td>\n                        <td id=\"T_11089_row6_col1\" class=\"data row6 col1\" >1.238049</td>\n                        <td id=\"T_11089_row6_col2\" class=\"data row6 col2\" >0.705584</td>\n                        <td id=\"T_11089_row6_col3\" class=\"data row6 col3\" >-1.218741</td>\n            </tr>\n            <tr>\n                        <th id=\"T_11089_level0_row7\" class=\"row_heading level0 row7\" >7</th>\n                        <td id=\"T_11089_row7_col0\" class=\"data row7 col0\" >-1.782425</td>\n                        <td id=\"T_11089_row7_col1\" class=\"data row7 col1\" >-0.117057</td>\n                        <td id=\"T_11089_row7_col2\" class=\"data row7 col2\" >0.323656</td>\n                        <td id=\"T_11089_row7_col3\" class=\"data row7 col3\" >-0.032317</td>\n            </tr>\n            <tr>\n                        <th id=\"T_11089_level0_row8\" class=\"row_heading level0 row8\" >8</th>\n                        <td id=\"T_11089_row8_col0\" class=\"data row8 col0\" >-0.005736</td>\n                        <td id=\"T_11089_row8_col1\" class=\"data row8 col1\" >0.664067</td>\n                        <td id=\"T_11089_row8_col2\" class=\"data row8 col2\" >-1.027564</td>\n                        <td id=\"T_11089_row8_col3\" class=\"data row8 col3\" >1.295308</td>\n            </tr>\n            <tr>\n                        <th id=\"T_11089_level0_row9\" class=\"row_heading level0 row9\" >9</th>\n                        <td id=\"T_11089_row9_col0\" class=\"data row9 col0\" >0.428075</td>\n                        <td id=\"T_11089_row9_col1\" class=\"data row9 col1\" >-1.257755</td>\n                        <td id=\"T_11089_row9_col2\" class=\"data row9 col2\" >-0.884078</td>\n                        <td id=\"T_11089_row9_col3\" class=\"data row9 col3\" >0.248043</td>\n            </tr>\n    </tbody></table>"
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 对指定列最大值高亮处理\n",
    "def highlight_max(s):\n",
    "    '''\n",
    "    对列最大值高亮（黄色）处理\n",
    "    '''\n",
    "    is_max = s == s.max()\n",
    "    return ['background-color: yellow' if v else '' for v in is_max]\n",
    "\n",
    "data.style.apply(highlight_max,subset=['A', 'B', 'C', 'D'])"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "outputs": [
    {
     "data": {
      "text/plain": "<pandas.io.formats.style.Styler at 0x139c605b0>",
      "text/html": "<style  type=\"text/css\" >\n#T_ae409_row0_col0,#T_ae409_row1_col0,#T_ae409_row2_col0,#T_ae409_row3_col0,#T_ae409_row4_col0,#T_ae409_row5_col0,#T_ae409_row6_col0,#T_ae409_row7_col0,#T_ae409_row8_col0{\n            color :  red;\n        }</style><table id=\"T_ae409_\" ><thead>    <tr>        <th class=\"blank level0\" ></th>        <th class=\"col_heading level0 col0\" >A</th>        <th class=\"col_heading level0 col1\" >B</th>        <th class=\"col_heading level0 col2\" >C</th>        <th class=\"col_heading level0 col3\" >D</th>    </tr></thead><tbody>\n                <tr>\n                        <th id=\"T_ae409_level0_row0\" class=\"row_heading level0 row0\" >0</th>\n                        <td id=\"T_ae409_row0_col0\" class=\"data row0 col0\" >-2.453970</td>\n                        <td id=\"T_ae409_row0_col1\" class=\"data row0 col1\" >0.564621</td>\n                        <td id=\"T_ae409_row0_col2\" class=\"data row0 col2\" >0.670272</td>\n                        <td id=\"T_ae409_row0_col3\" class=\"data row0 col3\" >-0.345173</td>\n            </tr>\n            <tr>\n                        <th id=\"T_ae409_level0_row1\" class=\"row_heading level0 row1\" >1</th>\n                        <td id=\"T_ae409_row1_col0\" class=\"data row1 col0\" >-0.124559</td>\n                        <td id=\"T_ae409_row1_col1\" class=\"data row1 col1\" >0.081625</td>\n                        <td id=\"T_ae409_row1_col2\" class=\"data row1 col2\" >0.382049</td>\n                        <td id=\"T_ae409_row1_col3\" class=\"data row1 col3\" >-0.449489</td>\n            </tr>\n            <tr>\n                        <th id=\"T_ae409_level0_row2\" class=\"row_heading level0 row2\" >2</th>\n                        <td id=\"T_ae409_row2_col0\" class=\"data row2 col0\" >-1.367770</td>\n                        <td id=\"T_ae409_row2_col1\" class=\"data row2 col1\" >0.362711</td>\n                        <td id=\"T_ae409_row2_col2\" class=\"data row2 col2\" >-0.085119</td>\n                        <td id=\"T_ae409_row2_col3\" class=\"data row2 col3\" >0.110784</td>\n            </tr>\n            <tr>\n                        <th id=\"T_ae409_level0_row3\" class=\"row_heading level0 row3\" >3</th>\n                        <td id=\"T_ae409_row3_col0\" class=\"data row3 col0\" >-1.535637</td>\n                        <td id=\"T_ae409_row3_col1\" class=\"data row3 col1\" >-0.109173</td>\n                        <td id=\"T_ae409_row3_col2\" class=\"data row3 col2\" >2.317123</td>\n                        <td id=\"T_ae409_row3_col3\" class=\"data row3 col3\" >-0.879901</td>\n            </tr>\n            <tr>\n                        <th id=\"T_ae409_level0_row4\" class=\"row_heading level0 row4\" >4</th>\n                        <td id=\"T_ae409_row4_col0\" class=\"data row4 col0\" >-1.007252</td>\n                        <td id=\"T_ae409_row4_col1\" class=\"data row4 col1\" >0.142094</td>\n                        <td id=\"T_ae409_row4_col2\" class=\"data row4 col2\" >-1.143808</td>\n                        <td id=\"T_ae409_row4_col3\" class=\"data row4 col3\" >0.918524</td>\n            </tr>\n            <tr>\n                        <th id=\"T_ae409_level0_row5\" class=\"row_heading level0 row5\" >5</th>\n                        <td id=\"T_ae409_row5_col0\" class=\"data row5 col0\" >-0.552521</td>\n                        <td id=\"T_ae409_row5_col1\" class=\"data row5 col1\" >1.484423</td>\n                        <td id=\"T_ae409_row5_col2\" class=\"data row5 col2\" >1.436369</td>\n                        <td id=\"T_ae409_row5_col3\" class=\"data row5 col3\" >0.382054</td>\n            </tr>\n            <tr>\n                        <th id=\"T_ae409_level0_row6\" class=\"row_heading level0 row6\" >6</th>\n                        <td id=\"T_ae409_row6_col0\" class=\"data row6 col0\" >-0.216479</td>\n                        <td id=\"T_ae409_row6_col1\" class=\"data row6 col1\" >1.238049</td>\n                        <td id=\"T_ae409_row6_col2\" class=\"data row6 col2\" >0.705584</td>\n                        <td id=\"T_ae409_row6_col3\" class=\"data row6 col3\" >-1.218741</td>\n            </tr>\n            <tr>\n                        <th id=\"T_ae409_level0_row7\" class=\"row_heading level0 row7\" >7</th>\n                        <td id=\"T_ae409_row7_col0\" class=\"data row7 col0\" >-1.782425</td>\n                        <td id=\"T_ae409_row7_col1\" class=\"data row7 col1\" >-0.117057</td>\n                        <td id=\"T_ae409_row7_col2\" class=\"data row7 col2\" >0.323656</td>\n                        <td id=\"T_ae409_row7_col3\" class=\"data row7 col3\" >-0.032317</td>\n            </tr>\n            <tr>\n                        <th id=\"T_ae409_level0_row8\" class=\"row_heading level0 row8\" >8</th>\n                        <td id=\"T_ae409_row8_col0\" class=\"data row8 col0\" >-0.005736</td>\n                        <td id=\"T_ae409_row8_col1\" class=\"data row8 col1\" >0.664067</td>\n                        <td id=\"T_ae409_row8_col2\" class=\"data row8 col2\" >-1.027564</td>\n                        <td id=\"T_ae409_row8_col3\" class=\"data row8 col3\" >1.295308</td>\n            </tr>\n            <tr>\n                        <th id=\"T_ae409_level0_row9\" class=\"row_heading level0 row9\" >9</th>\n                        <td id=\"T_ae409_row9_col0\" class=\"data row9 col0\" >0.428075</td>\n                        <td id=\"T_ae409_row9_col1\" class=\"data row9 col1\" >-1.257755</td>\n                        <td id=\"T_ae409_row9_col2\" class=\"data row9 col2\" >-0.884078</td>\n                        <td id=\"T_ae409_row9_col3\" class=\"data row9 col3\" >0.248043</td>\n            </tr>\n    </tbody></table>"
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 对指定条件的元素修改颜色\n",
    "def color_red(s):\n",
    "    is_max = s < 0\n",
    "    return ['color : red' if v else '' for v in is_max]\n",
    "# A列<0的数据标红\n",
    "data.style.apply(color_red,subset=['A'])"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 2. 数据条显示\n",
    "- 数据条显示，可视化数据大小"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "outputs": [
    {
     "data": {
      "text/plain": "<pandas.io.formats.style.Styler at 0x139c60df0>",
      "text/html": "<style  type=\"text/css\" >\n#T_9a847_row0_col0,#T_9a847_row9_col1{\n            width:  10em;\n             height:  80%;\n        }#T_9a847_row0_col1{\n            width:  10em;\n             height:  80%;\n            background:  linear-gradient(90deg,#FFA500 66.5%, transparent 66.5%);\n        }#T_9a847_row1_col0{\n            width:  10em;\n             height:  80%;\n            background:  linear-gradient(90deg,#FFA500 80.8%, transparent 80.8%);\n        }#T_9a847_row1_col1{\n            width:  10em;\n             height:  80%;\n            background:  linear-gradient(90deg,#FFA500 48.8%, transparent 48.8%);\n        }#T_9a847_row2_col0{\n            width:  10em;\n             height:  80%;\n            background:  linear-gradient(90deg,#FFA500 37.7%, transparent 37.7%);\n        }#T_9a847_row2_col1{\n            width:  10em;\n             height:  80%;\n            background:  linear-gradient(90deg,#FFA500 59.1%, transparent 59.1%);\n        }#T_9a847_row3_col0{\n            width:  10em;\n             height:  80%;\n            background:  linear-gradient(90deg,#FFA500 31.9%, transparent 31.9%);\n        }#T_9a847_row3_col1{\n            width:  10em;\n             height:  80%;\n            background:  linear-gradient(90deg,#FFA500 41.9%, transparent 41.9%);\n        }#T_9a847_row4_col0{\n            width:  10em;\n             height:  80%;\n            background:  linear-gradient(90deg,#FFA500 50.2%, transparent 50.2%);\n        }#T_9a847_row4_col1{\n            width:  10em;\n             height:  80%;\n            background:  linear-gradient(90deg,#FFA500 51.0%, transparent 51.0%);\n        }#T_9a847_row5_col0{\n            width:  10em;\n             height:  80%;\n            background:  linear-gradient(90deg,#FFA500 66.0%, transparent 66.0%);\n        }#T_9a847_row5_col1,#T_9a847_row9_col0{\n            width:  10em;\n             height:  80%;\n            background:  linear-gradient(90deg,#FFA500 100.0%, transparent 100.0%);\n        }#T_9a847_row6_col0{\n            width:  10em;\n             height:  80%;\n            background:  linear-gradient(90deg,#FFA500 77.6%, transparent 77.6%);\n        }#T_9a847_row6_col1{\n            width:  10em;\n             height:  80%;\n            background:  linear-gradient(90deg,#FFA500 91.0%, transparent 91.0%);\n        }#T_9a847_row7_col0{\n            width:  10em;\n             height:  80%;\n            background:  linear-gradient(90deg,#FFA500 23.3%, transparent 23.3%);\n        }#T_9a847_row7_col1{\n            width:  10em;\n             height:  80%;\n            background:  linear-gradient(90deg,#FFA500 41.6%, transparent 41.6%);\n        }#T_9a847_row8_col0{\n            width:  10em;\n             height:  80%;\n            background:  linear-gradient(90deg,#FFA500 84.9%, transparent 84.9%);\n        }#T_9a847_row8_col1{\n            width:  10em;\n             height:  80%;\n            background:  linear-gradient(90deg,#FFA500 70.1%, transparent 70.1%);\n        }</style><table id=\"T_9a847_\" ><thead>    <tr>        <th class=\"blank level0\" ></th>        <th class=\"col_heading level0 col0\" >A</th>        <th class=\"col_heading level0 col1\" >B</th>        <th class=\"col_heading level0 col2\" >C</th>        <th class=\"col_heading level0 col3\" >D</th>    </tr></thead><tbody>\n                <tr>\n                        <th id=\"T_9a847_level0_row0\" class=\"row_heading level0 row0\" >0</th>\n                        <td id=\"T_9a847_row0_col0\" class=\"data row0 col0\" >-2.453970</td>\n                        <td id=\"T_9a847_row0_col1\" class=\"data row0 col1\" >0.564621</td>\n                        <td id=\"T_9a847_row0_col2\" class=\"data row0 col2\" >0.670272</td>\n                        <td id=\"T_9a847_row0_col3\" class=\"data row0 col3\" >-0.345173</td>\n            </tr>\n            <tr>\n                        <th id=\"T_9a847_level0_row1\" class=\"row_heading level0 row1\" >1</th>\n                        <td id=\"T_9a847_row1_col0\" class=\"data row1 col0\" >-0.124559</td>\n                        <td id=\"T_9a847_row1_col1\" class=\"data row1 col1\" >0.081625</td>\n                        <td id=\"T_9a847_row1_col2\" class=\"data row1 col2\" >0.382049</td>\n                        <td id=\"T_9a847_row1_col3\" class=\"data row1 col3\" >-0.449489</td>\n            </tr>\n            <tr>\n                        <th id=\"T_9a847_level0_row2\" class=\"row_heading level0 row2\" >2</th>\n                        <td id=\"T_9a847_row2_col0\" class=\"data row2 col0\" >-1.367770</td>\n                        <td id=\"T_9a847_row2_col1\" class=\"data row2 col1\" >0.362711</td>\n                        <td id=\"T_9a847_row2_col2\" class=\"data row2 col2\" >-0.085119</td>\n                        <td id=\"T_9a847_row2_col3\" class=\"data row2 col3\" >0.110784</td>\n            </tr>\n            <tr>\n                        <th id=\"T_9a847_level0_row3\" class=\"row_heading level0 row3\" >3</th>\n                        <td id=\"T_9a847_row3_col0\" class=\"data row3 col0\" >-1.535637</td>\n                        <td id=\"T_9a847_row3_col1\" class=\"data row3 col1\" >-0.109173</td>\n                        <td id=\"T_9a847_row3_col2\" class=\"data row3 col2\" >2.317123</td>\n                        <td id=\"T_9a847_row3_col3\" class=\"data row3 col3\" >-0.879901</td>\n            </tr>\n            <tr>\n                        <th id=\"T_9a847_level0_row4\" class=\"row_heading level0 row4\" >4</th>\n                        <td id=\"T_9a847_row4_col0\" class=\"data row4 col0\" >-1.007252</td>\n                        <td id=\"T_9a847_row4_col1\" class=\"data row4 col1\" >0.142094</td>\n                        <td id=\"T_9a847_row4_col2\" class=\"data row4 col2\" >-1.143808</td>\n                        <td id=\"T_9a847_row4_col3\" class=\"data row4 col3\" >0.918524</td>\n            </tr>\n            <tr>\n                        <th id=\"T_9a847_level0_row5\" class=\"row_heading level0 row5\" >5</th>\n                        <td id=\"T_9a847_row5_col0\" class=\"data row5 col0\" >-0.552521</td>\n                        <td id=\"T_9a847_row5_col1\" class=\"data row5 col1\" >1.484423</td>\n                        <td id=\"T_9a847_row5_col2\" class=\"data row5 col2\" >1.436369</td>\n                        <td id=\"T_9a847_row5_col3\" class=\"data row5 col3\" >0.382054</td>\n            </tr>\n            <tr>\n                        <th id=\"T_9a847_level0_row6\" class=\"row_heading level0 row6\" >6</th>\n                        <td id=\"T_9a847_row6_col0\" class=\"data row6 col0\" >-0.216479</td>\n                        <td id=\"T_9a847_row6_col1\" class=\"data row6 col1\" >1.238049</td>\n                        <td id=\"T_9a847_row6_col2\" class=\"data row6 col2\" >0.705584</td>\n                        <td id=\"T_9a847_row6_col3\" class=\"data row6 col3\" >-1.218741</td>\n            </tr>\n            <tr>\n                        <th id=\"T_9a847_level0_row7\" class=\"row_heading level0 row7\" >7</th>\n                        <td id=\"T_9a847_row7_col0\" class=\"data row7 col0\" >-1.782425</td>\n                        <td id=\"T_9a847_row7_col1\" class=\"data row7 col1\" >-0.117057</td>\n                        <td id=\"T_9a847_row7_col2\" class=\"data row7 col2\" >0.323656</td>\n                        <td id=\"T_9a847_row7_col3\" class=\"data row7 col3\" >-0.032317</td>\n            </tr>\n            <tr>\n                        <th id=\"T_9a847_level0_row8\" class=\"row_heading level0 row8\" >8</th>\n                        <td id=\"T_9a847_row8_col0\" class=\"data row8 col0\" >-0.005736</td>\n                        <td id=\"T_9a847_row8_col1\" class=\"data row8 col1\" >0.664067</td>\n                        <td id=\"T_9a847_row8_col2\" class=\"data row8 col2\" >-1.027564</td>\n                        <td id=\"T_9a847_row8_col3\" class=\"data row8 col3\" >1.295308</td>\n            </tr>\n            <tr>\n                        <th id=\"T_9a847_level0_row9\" class=\"row_heading level0 row9\" >9</th>\n                        <td id=\"T_9a847_row9_col0\" class=\"data row9 col0\" >0.428075</td>\n                        <td id=\"T_9a847_row9_col1\" class=\"data row9 col1\" >-1.257755</td>\n                        <td id=\"T_9a847_row9_col2\" class=\"data row9 col2\" >-0.884078</td>\n                        <td id=\"T_9a847_row9_col3\" class=\"data row9 col3\" >0.248043</td>\n            </tr>\n    </tbody></table>"
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 数据条显示指定列数据大小\n",
    "data.style.bar(subset=['A', 'B'], color='#FFA500')"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 3. 色阶显示\n",
    "- 色阶表达数据大小\n",
    "- 调节色阶范围"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "outputs": [
    {
     "data": {
      "text/plain": "<pandas.io.formats.style.Styler at 0x139c518e0>",
      "text/html": "<style  type=\"text/css\" >\n#T_418c6_row0_col0,#T_418c6_row4_col2,#T_418c6_row6_col3,#T_418c6_row9_col1{\n            background-color:  #ebf3eb;\n            color:  #000000;\n        }#T_418c6_row0_col1{\n            background-color:  #4ea64e;\n            color:  #000000;\n        }#T_418c6_row0_col2{\n            background-color:  #6fb76f;\n            color:  #000000;\n        }#T_418c6_row0_col3{\n            background-color:  #9acb9a;\n            color:  #000000;\n        }#T_418c6_row1_col0{\n            background-color:  #2d962d;\n            color:  #000000;\n        }#T_418c6_row1_col1{\n            background-color:  #78bb78;\n            color:  #000000;\n        }#T_418c6_row1_col2{\n            background-color:  #84c084;\n            color:  #000000;\n        }#T_418c6_row1_col3,#T_418c6_row2_col2{\n            background-color:  #a3d0a3;\n            color:  #000000;\n        }#T_418c6_row2_col0{\n            background-color:  #92c892;\n            color:  #000000;\n        }#T_418c6_row2_col1{\n            background-color:  #60af60;\n            color:  #000000;\n        }#T_418c6_row2_col3{\n            background-color:  #6eb66e;\n            color:  #000000;\n        }#T_418c6_row3_col0{\n            background-color:  #a0cea0;\n            color:  #000000;\n        }#T_418c6_row3_col1{\n            background-color:  #88c388;\n            color:  #000000;\n        }#T_418c6_row3_col2,#T_418c6_row5_col1,#T_418c6_row8_col3,#T_418c6_row9_col0{\n            background-color:  #008000;\n            color:  #f1f1f1;\n        }#T_418c6_row3_col3{\n            background-color:  #cbe4cb;\n            color:  #000000;\n        }#T_418c6_row4_col0{\n            background-color:  #75b975;\n            color:  #000000;\n        }#T_418c6_row4_col1{\n            background-color:  #73b873;\n            color:  #000000;\n        }#T_418c6_row4_col3,#T_418c6_row8_col0{\n            background-color:  #239123;\n            color:  #000000;\n        }#T_418c6_row5_col0{\n            background-color:  #50a750;\n            color:  #000000;\n        }#T_418c6_row5_col2{\n            background-color:  #3c9d3c;\n            color:  #000000;\n        }#T_418c6_row5_col3{\n            background-color:  #55a955;\n            color:  #000000;\n        }#T_418c6_row6_col0{\n            background-color:  #349a34;\n            color:  #000000;\n        }#T_418c6_row6_col1{\n            background-color:  #158a15;\n            color:  #000000;\n        }#T_418c6_row6_col2{\n            background-color:  #6db66d;\n            color:  #000000;\n        }#T_418c6_row7_col0{\n            background-color:  #b4d8b4;\n            color:  #000000;\n        }#T_418c6_row7_col1{\n            background-color:  #89c389;\n            color:  #000000;\n        }#T_418c6_row7_col2{\n            background-color:  #87c287;\n            color:  #000000;\n        }#T_418c6_row7_col3{\n            background-color:  #7cbd7c;\n            color:  #000000;\n        }#T_418c6_row8_col1{\n            background-color:  #46a246;\n            color:  #000000;\n        }#T_418c6_row8_col2{\n            background-color:  #e3efe3;\n            color:  #000000;\n        }#T_418c6_row9_col2{\n            background-color:  #d9ead9;\n            color:  #000000;\n        }#T_418c6_row9_col3{\n            background-color:  #61b061;\n            color:  #000000;\n        }</style><table id=\"T_418c6_\" ><thead>    <tr>        <th class=\"blank level0\" ></th>        <th class=\"col_heading level0 col0\" >A</th>        <th class=\"col_heading level0 col1\" >B</th>        <th class=\"col_heading level0 col2\" >C</th>        <th class=\"col_heading level0 col3\" >D</th>    </tr></thead><tbody>\n                <tr>\n                        <th id=\"T_418c6_level0_row0\" class=\"row_heading level0 row0\" >0</th>\n                        <td id=\"T_418c6_row0_col0\" class=\"data row0 col0\" >-2.453970</td>\n                        <td id=\"T_418c6_row0_col1\" class=\"data row0 col1\" >0.564621</td>\n                        <td id=\"T_418c6_row0_col2\" class=\"data row0 col2\" >0.670272</td>\n                        <td id=\"T_418c6_row0_col3\" class=\"data row0 col3\" >-0.345173</td>\n            </tr>\n            <tr>\n                        <th id=\"T_418c6_level0_row1\" class=\"row_heading level0 row1\" >1</th>\n                        <td id=\"T_418c6_row1_col0\" class=\"data row1 col0\" >-0.124559</td>\n                        <td id=\"T_418c6_row1_col1\" class=\"data row1 col1\" >0.081625</td>\n                        <td id=\"T_418c6_row1_col2\" class=\"data row1 col2\" >0.382049</td>\n                        <td id=\"T_418c6_row1_col3\" class=\"data row1 col3\" >-0.449489</td>\n            </tr>\n            <tr>\n                        <th id=\"T_418c6_level0_row2\" class=\"row_heading level0 row2\" >2</th>\n                        <td id=\"T_418c6_row2_col0\" class=\"data row2 col0\" >-1.367770</td>\n                        <td id=\"T_418c6_row2_col1\" class=\"data row2 col1\" >0.362711</td>\n                        <td id=\"T_418c6_row2_col2\" class=\"data row2 col2\" >-0.085119</td>\n                        <td id=\"T_418c6_row2_col3\" class=\"data row2 col3\" >0.110784</td>\n            </tr>\n            <tr>\n                        <th id=\"T_418c6_level0_row3\" class=\"row_heading level0 row3\" >3</th>\n                        <td id=\"T_418c6_row3_col0\" class=\"data row3 col0\" >-1.535637</td>\n                        <td id=\"T_418c6_row3_col1\" class=\"data row3 col1\" >-0.109173</td>\n                        <td id=\"T_418c6_row3_col2\" class=\"data row3 col2\" >2.317123</td>\n                        <td id=\"T_418c6_row3_col3\" class=\"data row3 col3\" >-0.879901</td>\n            </tr>\n            <tr>\n                        <th id=\"T_418c6_level0_row4\" class=\"row_heading level0 row4\" >4</th>\n                        <td id=\"T_418c6_row4_col0\" class=\"data row4 col0\" >-1.007252</td>\n                        <td id=\"T_418c6_row4_col1\" class=\"data row4 col1\" >0.142094</td>\n                        <td id=\"T_418c6_row4_col2\" class=\"data row4 col2\" >-1.143808</td>\n                        <td id=\"T_418c6_row4_col3\" class=\"data row4 col3\" >0.918524</td>\n            </tr>\n            <tr>\n                        <th id=\"T_418c6_level0_row5\" class=\"row_heading level0 row5\" >5</th>\n                        <td id=\"T_418c6_row5_col0\" class=\"data row5 col0\" >-0.552521</td>\n                        <td id=\"T_418c6_row5_col1\" class=\"data row5 col1\" >1.484423</td>\n                        <td id=\"T_418c6_row5_col2\" class=\"data row5 col2\" >1.436369</td>\n                        <td id=\"T_418c6_row5_col3\" class=\"data row5 col3\" >0.382054</td>\n            </tr>\n            <tr>\n                        <th id=\"T_418c6_level0_row6\" class=\"row_heading level0 row6\" >6</th>\n                        <td id=\"T_418c6_row6_col0\" class=\"data row6 col0\" >-0.216479</td>\n                        <td id=\"T_418c6_row6_col1\" class=\"data row6 col1\" >1.238049</td>\n                        <td id=\"T_418c6_row6_col2\" class=\"data row6 col2\" >0.705584</td>\n                        <td id=\"T_418c6_row6_col3\" class=\"data row6 col3\" >-1.218741</td>\n            </tr>\n            <tr>\n                        <th id=\"T_418c6_level0_row7\" class=\"row_heading level0 row7\" >7</th>\n                        <td id=\"T_418c6_row7_col0\" class=\"data row7 col0\" >-1.782425</td>\n                        <td id=\"T_418c6_row7_col1\" class=\"data row7 col1\" >-0.117057</td>\n                        <td id=\"T_418c6_row7_col2\" class=\"data row7 col2\" >0.323656</td>\n                        <td id=\"T_418c6_row7_col3\" class=\"data row7 col3\" >-0.032317</td>\n            </tr>\n            <tr>\n                        <th id=\"T_418c6_level0_row8\" class=\"row_heading level0 row8\" >8</th>\n                        <td id=\"T_418c6_row8_col0\" class=\"data row8 col0\" >-0.005736</td>\n                        <td id=\"T_418c6_row8_col1\" class=\"data row8 col1\" >0.664067</td>\n                        <td id=\"T_418c6_row8_col2\" class=\"data row8 col2\" >-1.027564</td>\n                        <td id=\"T_418c6_row8_col3\" class=\"data row8 col3\" >1.295308</td>\n            </tr>\n            <tr>\n                        <th id=\"T_418c6_level0_row9\" class=\"row_heading level0 row9\" >9</th>\n                        <td id=\"T_418c6_row9_col0\" class=\"data row9 col0\" >0.428075</td>\n                        <td id=\"T_418c6_row9_col1\" class=\"data row9 col1\" >-1.257755</td>\n                        <td id=\"T_418c6_row9_col2\" class=\"data row9 col2\" >-0.884078</td>\n                        <td id=\"T_418c6_row9_col3\" class=\"data row9 col3\" >0.248043</td>\n            </tr>\n    </tbody></table>"
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import seaborn as sns\n",
    "\n",
    "# 使用seaborn获取颜色\n",
    "cm = sns.light_palette(\"green\", as_cmap=True)\n",
    "# 色阶实现\n",
    "data.style.background_gradient(cmap=cm,subset=['A', 'B', 'C', 'D'])"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "outputs": [
    {
     "data": {
      "text/plain": "<pandas.io.formats.style.Styler at 0x139c6be50>",
      "text/html": "<style  type=\"text/css\" >\n#T_8cf3c_row0_col0,#T_8cf3c_row4_col2,#T_8cf3c_row6_col3,#T_8cf3c_row9_col1{\n            background-color:  #481c6e;\n            color:  #f1f1f1;\n        }#T_8cf3c_row0_col1{\n            background-color:  #21a585;\n            color:  #000000;\n        }#T_8cf3c_row0_col2{\n            background-color:  #228b8d;\n            color:  #000000;\n        }#T_8cf3c_row0_col3{\n            background-color:  #2f6b8e;\n            color:  #f1f1f1;\n        }#T_8cf3c_row1_col0{\n            background-color:  #42be71;\n            color:  #000000;\n        }#T_8cf3c_row1_col1{\n            background-color:  #25848e;\n            color:  #000000;\n        }#T_8cf3c_row1_col2{\n            background-color:  #287c8e;\n            color:  #000000;\n        }#T_8cf3c_row1_col3,#T_8cf3c_row2_col2{\n            background-color:  #33628d;\n            color:  #f1f1f1;\n        }#T_8cf3c_row2_col0{\n            background-color:  #2d708e;\n            color:  #f1f1f1;\n        }#T_8cf3c_row2_col1{\n            background-color:  #1f988b;\n            color:  #000000;\n        }#T_8cf3c_row2_col3{\n            background-color:  #228c8d;\n            color:  #000000;\n        }#T_8cf3c_row3_col0{\n            background-color:  #32658e;\n            color:  #f1f1f1;\n        }#T_8cf3c_row3_col1{\n            background-color:  #2a788e;\n            color:  #000000;\n        }#T_8cf3c_row3_col2,#T_8cf3c_row5_col1,#T_8cf3c_row8_col3,#T_8cf3c_row9_col0{\n            background-color:  #98d83e;\n            color:  #000000;\n        }#T_8cf3c_row3_col3{\n            background-color:  #433e85;\n            color:  #f1f1f1;\n        }#T_8cf3c_row4_col0{\n            background-color:  #24878e;\n            color:  #000000;\n        }#T_8cf3c_row4_col1{\n            background-color:  #23898e;\n            color:  #000000;\n        }#T_8cf3c_row4_col3{\n            background-color:  #54c568;\n            color:  #000000;\n        }#T_8cf3c_row5_col0{\n            background-color:  #20a486;\n            color:  #000000;\n        }#T_8cf3c_row5_col2{\n            background-color:  #2fb47c;\n            color:  #000000;\n        }#T_8cf3c_row5_col3{\n            background-color:  #1fa188;\n            color:  #000000;\n        }#T_8cf3c_row6_col0{\n            background-color:  #38b977;\n            color:  #000000;\n        }#T_8cf3c_row6_col1{\n            background-color:  #6ccd5a;\n            color:  #000000;\n        }#T_8cf3c_row6_col2{\n            background-color:  #228d8d;\n            color:  #000000;\n        }#T_8cf3c_row7_col0{\n            background-color:  #3a538b;\n            color:  #f1f1f1;\n        }#T_8cf3c_row7_col1{\n            background-color:  #2a778e;\n            color:  #000000;\n        }#T_8cf3c_row7_col2{\n            background-color:  #29798e;\n            color:  #000000;\n        }#T_8cf3c_row7_col3{\n            background-color:  #26828e;\n            color:  #000000;\n        }#T_8cf3c_row8_col0{\n            background-color:  #52c569;\n            color:  #000000;\n        }#T_8cf3c_row8_col1{\n            background-color:  #25ac82;\n            color:  #000000;\n        }#T_8cf3c_row8_col2{\n            background-color:  #482576;\n            color:  #f1f1f1;\n        }#T_8cf3c_row9_col2{\n            background-color:  #472f7d;\n            color:  #f1f1f1;\n        }#T_8cf3c_row9_col3{\n            background-color:  #1f968b;\n            color:  #000000;\n        }</style><table id=\"T_8cf3c_\" ><thead>    <tr>        <th class=\"blank level0\" ></th>        <th class=\"col_heading level0 col0\" >A</th>        <th class=\"col_heading level0 col1\" >B</th>        <th class=\"col_heading level0 col2\" >C</th>        <th class=\"col_heading level0 col3\" >D</th>    </tr></thead><tbody>\n                <tr>\n                        <th id=\"T_8cf3c_level0_row0\" class=\"row_heading level0 row0\" >0</th>\n                        <td id=\"T_8cf3c_row0_col0\" class=\"data row0 col0\" >-2.453970</td>\n                        <td id=\"T_8cf3c_row0_col1\" class=\"data row0 col1\" >0.564621</td>\n                        <td id=\"T_8cf3c_row0_col2\" class=\"data row0 col2\" >0.670272</td>\n                        <td id=\"T_8cf3c_row0_col3\" class=\"data row0 col3\" >-0.345173</td>\n            </tr>\n            <tr>\n                        <th id=\"T_8cf3c_level0_row1\" class=\"row_heading level0 row1\" >1</th>\n                        <td id=\"T_8cf3c_row1_col0\" class=\"data row1 col0\" >-0.124559</td>\n                        <td id=\"T_8cf3c_row1_col1\" class=\"data row1 col1\" >0.081625</td>\n                        <td id=\"T_8cf3c_row1_col2\" class=\"data row1 col2\" >0.382049</td>\n                        <td id=\"T_8cf3c_row1_col3\" class=\"data row1 col3\" >-0.449489</td>\n            </tr>\n            <tr>\n                        <th id=\"T_8cf3c_level0_row2\" class=\"row_heading level0 row2\" >2</th>\n                        <td id=\"T_8cf3c_row2_col0\" class=\"data row2 col0\" >-1.367770</td>\n                        <td id=\"T_8cf3c_row2_col1\" class=\"data row2 col1\" >0.362711</td>\n                        <td id=\"T_8cf3c_row2_col2\" class=\"data row2 col2\" >-0.085119</td>\n                        <td id=\"T_8cf3c_row2_col3\" class=\"data row2 col3\" >0.110784</td>\n            </tr>\n            <tr>\n                        <th id=\"T_8cf3c_level0_row3\" class=\"row_heading level0 row3\" >3</th>\n                        <td id=\"T_8cf3c_row3_col0\" class=\"data row3 col0\" >-1.535637</td>\n                        <td id=\"T_8cf3c_row3_col1\" class=\"data row3 col1\" >-0.109173</td>\n                        <td id=\"T_8cf3c_row3_col2\" class=\"data row3 col2\" >2.317123</td>\n                        <td id=\"T_8cf3c_row3_col3\" class=\"data row3 col3\" >-0.879901</td>\n            </tr>\n            <tr>\n                        <th id=\"T_8cf3c_level0_row4\" class=\"row_heading level0 row4\" >4</th>\n                        <td id=\"T_8cf3c_row4_col0\" class=\"data row4 col0\" >-1.007252</td>\n                        <td id=\"T_8cf3c_row4_col1\" class=\"data row4 col1\" >0.142094</td>\n                        <td id=\"T_8cf3c_row4_col2\" class=\"data row4 col2\" >-1.143808</td>\n                        <td id=\"T_8cf3c_row4_col3\" class=\"data row4 col3\" >0.918524</td>\n            </tr>\n            <tr>\n                        <th id=\"T_8cf3c_level0_row5\" class=\"row_heading level0 row5\" >5</th>\n                        <td id=\"T_8cf3c_row5_col0\" class=\"data row5 col0\" >-0.552521</td>\n                        <td id=\"T_8cf3c_row5_col1\" class=\"data row5 col1\" >1.484423</td>\n                        <td id=\"T_8cf3c_row5_col2\" class=\"data row5 col2\" >1.436369</td>\n                        <td id=\"T_8cf3c_row5_col3\" class=\"data row5 col3\" >0.382054</td>\n            </tr>\n            <tr>\n                        <th id=\"T_8cf3c_level0_row6\" class=\"row_heading level0 row6\" >6</th>\n                        <td id=\"T_8cf3c_row6_col0\" class=\"data row6 col0\" >-0.216479</td>\n                        <td id=\"T_8cf3c_row6_col1\" class=\"data row6 col1\" >1.238049</td>\n                        <td id=\"T_8cf3c_row6_col2\" class=\"data row6 col2\" >0.705584</td>\n                        <td id=\"T_8cf3c_row6_col3\" class=\"data row6 col3\" >-1.218741</td>\n            </tr>\n            <tr>\n                        <th id=\"T_8cf3c_level0_row7\" class=\"row_heading level0 row7\" >7</th>\n                        <td id=\"T_8cf3c_row7_col0\" class=\"data row7 col0\" >-1.782425</td>\n                        <td id=\"T_8cf3c_row7_col1\" class=\"data row7 col1\" >-0.117057</td>\n                        <td id=\"T_8cf3c_row7_col2\" class=\"data row7 col2\" >0.323656</td>\n                        <td id=\"T_8cf3c_row7_col3\" class=\"data row7 col3\" >-0.032317</td>\n            </tr>\n            <tr>\n                        <th id=\"T_8cf3c_level0_row8\" class=\"row_heading level0 row8\" >8</th>\n                        <td id=\"T_8cf3c_row8_col0\" class=\"data row8 col0\" >-0.005736</td>\n                        <td id=\"T_8cf3c_row8_col1\" class=\"data row8 col1\" >0.664067</td>\n                        <td id=\"T_8cf3c_row8_col2\" class=\"data row8 col2\" >-1.027564</td>\n                        <td id=\"T_8cf3c_row8_col3\" class=\"data row8 col3\" >1.295308</td>\n            </tr>\n            <tr>\n                        <th id=\"T_8cf3c_level0_row9\" class=\"row_heading level0 row9\" >9</th>\n                        <td id=\"T_8cf3c_row9_col0\" class=\"data row9 col0\" >0.428075</td>\n                        <td id=\"T_8cf3c_row9_col1\" class=\"data row9 col1\" >-1.257755</td>\n                        <td id=\"T_8cf3c_row9_col2\" class=\"data row9 col2\" >-0.884078</td>\n                        <td id=\"T_8cf3c_row9_col3\" class=\"data row9 col3\" >0.248043</td>\n            </tr>\n    </tbody></table>"
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 调节前\n",
    "# 色阶实现,这里使用内置色阶类型，不调节颜色范围\n",
    "data.style.background_gradient(cmap='viridis',high=0.2,low=0.1,subset=['A', 'B', 'C', 'D'])"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "outputs": [
    {
     "data": {
      "text/plain": "<pandas.io.formats.style.Styler at 0x139c6bcd0>",
      "text/html": "<style  type=\"text/css\" >\n#T_24856_row0_col0,#T_24856_row4_col2,#T_24856_row6_col3,#T_24856_row9_col1{\n            background-color:  #443983;\n            color:  #f1f1f1;\n        }#T_24856_row0_col1{\n            background-color:  #1f998a;\n            color:  #000000;\n        }#T_24856_row0_col2,#T_24856_row2_col3{\n            background-color:  #24868e;\n            color:  #000000;\n        }#T_24856_row0_col3{\n            background-color:  #2e6f8e;\n            color:  #f1f1f1;\n        }#T_24856_row1_col0{\n            background-color:  #25ac82;\n            color:  #000000;\n        }#T_24856_row1_col1{\n            background-color:  #26828e;\n            color:  #000000;\n        }#T_24856_row1_col2{\n            background-color:  #297b8e;\n            color:  #000000;\n        }#T_24856_row1_col3,#T_24856_row2_col2{\n            background-color:  #30698e;\n            color:  #f1f1f1;\n        }#T_24856_row2_col0{\n            background-color:  #2c728e;\n            color:  #f1f1f1;\n        }#T_24856_row2_col1{\n            background-color:  #218f8d;\n            color:  #000000;\n        }#T_24856_row3_col0{\n            background-color:  #306a8e;\n            color:  #f1f1f1;\n        }#T_24856_row3_col1,#T_24856_row7_col2{\n            background-color:  #2a788e;\n            color:  #000000;\n        }#T_24856_row3_col2,#T_24856_row5_col1,#T_24856_row8_col3,#T_24856_row9_col0{\n            background-color:  #4ec36b;\n            color:  #000000;\n        }#T_24856_row3_col3{\n            background-color:  #3c4f8a;\n            color:  #f1f1f1;\n        }#T_24856_row4_col0{\n            background-color:  #25838e;\n            color:  #000000;\n        }#T_24856_row4_col1{\n            background-color:  #25848e;\n            color:  #000000;\n        }#T_24856_row4_col3,#T_24856_row8_col0{\n            background-color:  #2cb17e;\n            color:  #000000;\n        }#T_24856_row5_col0{\n            background-color:  #1f988b;\n            color:  #000000;\n        }#T_24856_row5_col2{\n            background-color:  #20a386;\n            color:  #000000;\n        }#T_24856_row5_col3{\n            background-color:  #1f958b;\n            color:  #000000;\n        }#T_24856_row6_col0{\n            background-color:  #22a884;\n            color:  #000000;\n        }#T_24856_row6_col1{\n            background-color:  #38b977;\n            color:  #000000;\n        }#T_24856_row6_col2{\n            background-color:  #24878e;\n            color:  #000000;\n        }#T_24856_row7_col0{\n            background-color:  #355e8d;\n            color:  #f1f1f1;\n        }#T_24856_row7_col1{\n            background-color:  #2a778e;\n            color:  #000000;\n        }#T_24856_row7_col3{\n            background-color:  #277f8e;\n            color:  #000000;\n        }#T_24856_row8_col1{\n            background-color:  #1f9e89;\n            color:  #000000;\n        }#T_24856_row8_col2{\n            background-color:  #423f85;\n            color:  #f1f1f1;\n        }#T_24856_row9_col2{\n            background-color:  #404688;\n            color:  #f1f1f1;\n        }#T_24856_row9_col3{\n            background-color:  #218e8d;\n            color:  #000000;\n        }</style><table id=\"T_24856_\" ><thead>    <tr>        <th class=\"blank level0\" ></th>        <th class=\"col_heading level0 col0\" >A</th>        <th class=\"col_heading level0 col1\" >B</th>        <th class=\"col_heading level0 col2\" >C</th>        <th class=\"col_heading level0 col3\" >D</th>    </tr></thead><tbody>\n                <tr>\n                        <th id=\"T_24856_level0_row0\" class=\"row_heading level0 row0\" >0</th>\n                        <td id=\"T_24856_row0_col0\" class=\"data row0 col0\" >-2.453970</td>\n                        <td id=\"T_24856_row0_col1\" class=\"data row0 col1\" >0.564621</td>\n                        <td id=\"T_24856_row0_col2\" class=\"data row0 col2\" >0.670272</td>\n                        <td id=\"T_24856_row0_col3\" class=\"data row0 col3\" >-0.345173</td>\n            </tr>\n            <tr>\n                        <th id=\"T_24856_level0_row1\" class=\"row_heading level0 row1\" >1</th>\n                        <td id=\"T_24856_row1_col0\" class=\"data row1 col0\" >-0.124559</td>\n                        <td id=\"T_24856_row1_col1\" class=\"data row1 col1\" >0.081625</td>\n                        <td id=\"T_24856_row1_col2\" class=\"data row1 col2\" >0.382049</td>\n                        <td id=\"T_24856_row1_col3\" class=\"data row1 col3\" >-0.449489</td>\n            </tr>\n            <tr>\n                        <th id=\"T_24856_level0_row2\" class=\"row_heading level0 row2\" >2</th>\n                        <td id=\"T_24856_row2_col0\" class=\"data row2 col0\" >-1.367770</td>\n                        <td id=\"T_24856_row2_col1\" class=\"data row2 col1\" >0.362711</td>\n                        <td id=\"T_24856_row2_col2\" class=\"data row2 col2\" >-0.085119</td>\n                        <td id=\"T_24856_row2_col3\" class=\"data row2 col3\" >0.110784</td>\n            </tr>\n            <tr>\n                        <th id=\"T_24856_level0_row3\" class=\"row_heading level0 row3\" >3</th>\n                        <td id=\"T_24856_row3_col0\" class=\"data row3 col0\" >-1.535637</td>\n                        <td id=\"T_24856_row3_col1\" class=\"data row3 col1\" >-0.109173</td>\n                        <td id=\"T_24856_row3_col2\" class=\"data row3 col2\" >2.317123</td>\n                        <td id=\"T_24856_row3_col3\" class=\"data row3 col3\" >-0.879901</td>\n            </tr>\n            <tr>\n                        <th id=\"T_24856_level0_row4\" class=\"row_heading level0 row4\" >4</th>\n                        <td id=\"T_24856_row4_col0\" class=\"data row4 col0\" >-1.007252</td>\n                        <td id=\"T_24856_row4_col1\" class=\"data row4 col1\" >0.142094</td>\n                        <td id=\"T_24856_row4_col2\" class=\"data row4 col2\" >-1.143808</td>\n                        <td id=\"T_24856_row4_col3\" class=\"data row4 col3\" >0.918524</td>\n            </tr>\n            <tr>\n                        <th id=\"T_24856_level0_row5\" class=\"row_heading level0 row5\" >5</th>\n                        <td id=\"T_24856_row5_col0\" class=\"data row5 col0\" >-0.552521</td>\n                        <td id=\"T_24856_row5_col1\" class=\"data row5 col1\" >1.484423</td>\n                        <td id=\"T_24856_row5_col2\" class=\"data row5 col2\" >1.436369</td>\n                        <td id=\"T_24856_row5_col3\" class=\"data row5 col3\" >0.382054</td>\n            </tr>\n            <tr>\n                        <th id=\"T_24856_level0_row6\" class=\"row_heading level0 row6\" >6</th>\n                        <td id=\"T_24856_row6_col0\" class=\"data row6 col0\" >-0.216479</td>\n                        <td id=\"T_24856_row6_col1\" class=\"data row6 col1\" >1.238049</td>\n                        <td id=\"T_24856_row6_col2\" class=\"data row6 col2\" >0.705584</td>\n                        <td id=\"T_24856_row6_col3\" class=\"data row6 col3\" >-1.218741</td>\n            </tr>\n            <tr>\n                        <th id=\"T_24856_level0_row7\" class=\"row_heading level0 row7\" >7</th>\n                        <td id=\"T_24856_row7_col0\" class=\"data row7 col0\" >-1.782425</td>\n                        <td id=\"T_24856_row7_col1\" class=\"data row7 col1\" >-0.117057</td>\n                        <td id=\"T_24856_row7_col2\" class=\"data row7 col2\" >0.323656</td>\n                        <td id=\"T_24856_row7_col3\" class=\"data row7 col3\" >-0.032317</td>\n            </tr>\n            <tr>\n                        <th id=\"T_24856_level0_row8\" class=\"row_heading level0 row8\" >8</th>\n                        <td id=\"T_24856_row8_col0\" class=\"data row8 col0\" >-0.005736</td>\n                        <td id=\"T_24856_row8_col1\" class=\"data row8 col1\" >0.664067</td>\n                        <td id=\"T_24856_row8_col2\" class=\"data row8 col2\" >-1.027564</td>\n                        <td id=\"T_24856_row8_col3\" class=\"data row8 col3\" >1.295308</td>\n            </tr>\n            <tr>\n                        <th id=\"T_24856_level0_row9\" class=\"row_heading level0 row9\" >9</th>\n                        <td id=\"T_24856_row9_col0\" class=\"data row9 col0\" >0.428075</td>\n                        <td id=\"T_24856_row9_col1\" class=\"data row9 col1\" >-1.257755</td>\n                        <td id=\"T_24856_row9_col2\" class=\"data row9 col2\" >-0.884078</td>\n                        <td id=\"T_24856_row9_col3\" class=\"data row9 col3\" >0.248043</td>\n            </tr>\n    </tbody></table>"
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 调节后\n",
    "# 色阶实现,这里使用内置色阶类型，调节颜色范围\n",
    "data.style.background_gradient(cmap='viridis',high=0.5,low=0.3,subset=['A', 'B', 'C', 'D'])"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 4. 百分比显示\n",
    "- 百分比显示数字"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "outputs": [
    {
     "data": {
      "text/plain": "<pandas.io.formats.style.Styler at 0x139c9cd00>",
      "text/html": "<style  type=\"text/css\" >\n</style><table id=\"T_b8b02_\" ><thead>    <tr>        <th class=\"blank level0\" ></th>        <th class=\"col_heading level0 col0\" >A</th>        <th class=\"col_heading level0 col1\" >B</th>        <th class=\"col_heading level0 col2\" >C</th>        <th class=\"col_heading level0 col3\" >D</th>    </tr></thead><tbody>\n                <tr>\n                        <th id=\"T_b8b02_level0_row0\" class=\"row_heading level0 row0\" >0</th>\n                        <td id=\"T_b8b02_row0_col0\" class=\"data row0 col0\" >-245.40%</td>\n                        <td id=\"T_b8b02_row0_col1\" class=\"data row0 col1\" >56.46%</td>\n                        <td id=\"T_b8b02_row0_col2\" class=\"data row0 col2\" >0.670272</td>\n                        <td id=\"T_b8b02_row0_col3\" class=\"data row0 col3\" >-0.345173</td>\n            </tr>\n            <tr>\n                        <th id=\"T_b8b02_level0_row1\" class=\"row_heading level0 row1\" >1</th>\n                        <td id=\"T_b8b02_row1_col0\" class=\"data row1 col0\" >-12.46%</td>\n                        <td id=\"T_b8b02_row1_col1\" class=\"data row1 col1\" >8.16%</td>\n                        <td id=\"T_b8b02_row1_col2\" class=\"data row1 col2\" >0.382049</td>\n                        <td id=\"T_b8b02_row1_col3\" class=\"data row1 col3\" >-0.449489</td>\n            </tr>\n            <tr>\n                        <th id=\"T_b8b02_level0_row2\" class=\"row_heading level0 row2\" >2</th>\n                        <td id=\"T_b8b02_row2_col0\" class=\"data row2 col0\" >-136.78%</td>\n                        <td id=\"T_b8b02_row2_col1\" class=\"data row2 col1\" >36.27%</td>\n                        <td id=\"T_b8b02_row2_col2\" class=\"data row2 col2\" >-0.085119</td>\n                        <td id=\"T_b8b02_row2_col3\" class=\"data row2 col3\" >0.110784</td>\n            </tr>\n            <tr>\n                        <th id=\"T_b8b02_level0_row3\" class=\"row_heading level0 row3\" >3</th>\n                        <td id=\"T_b8b02_row3_col0\" class=\"data row3 col0\" >-153.56%</td>\n                        <td id=\"T_b8b02_row3_col1\" class=\"data row3 col1\" >-10.92%</td>\n                        <td id=\"T_b8b02_row3_col2\" class=\"data row3 col2\" >2.317123</td>\n                        <td id=\"T_b8b02_row3_col3\" class=\"data row3 col3\" >-0.879901</td>\n            </tr>\n            <tr>\n                        <th id=\"T_b8b02_level0_row4\" class=\"row_heading level0 row4\" >4</th>\n                        <td id=\"T_b8b02_row4_col0\" class=\"data row4 col0\" >-100.73%</td>\n                        <td id=\"T_b8b02_row4_col1\" class=\"data row4 col1\" >14.21%</td>\n                        <td id=\"T_b8b02_row4_col2\" class=\"data row4 col2\" >-1.143808</td>\n                        <td id=\"T_b8b02_row4_col3\" class=\"data row4 col3\" >0.918524</td>\n            </tr>\n            <tr>\n                        <th id=\"T_b8b02_level0_row5\" class=\"row_heading level0 row5\" >5</th>\n                        <td id=\"T_b8b02_row5_col0\" class=\"data row5 col0\" >-55.25%</td>\n                        <td id=\"T_b8b02_row5_col1\" class=\"data row5 col1\" >148.44%</td>\n                        <td id=\"T_b8b02_row5_col2\" class=\"data row5 col2\" >1.436369</td>\n                        <td id=\"T_b8b02_row5_col3\" class=\"data row5 col3\" >0.382054</td>\n            </tr>\n            <tr>\n                        <th id=\"T_b8b02_level0_row6\" class=\"row_heading level0 row6\" >6</th>\n                        <td id=\"T_b8b02_row6_col0\" class=\"data row6 col0\" >-21.65%</td>\n                        <td id=\"T_b8b02_row6_col1\" class=\"data row6 col1\" >123.80%</td>\n                        <td id=\"T_b8b02_row6_col2\" class=\"data row6 col2\" >0.705584</td>\n                        <td id=\"T_b8b02_row6_col3\" class=\"data row6 col3\" >-1.218741</td>\n            </tr>\n            <tr>\n                        <th id=\"T_b8b02_level0_row7\" class=\"row_heading level0 row7\" >7</th>\n                        <td id=\"T_b8b02_row7_col0\" class=\"data row7 col0\" >-178.24%</td>\n                        <td id=\"T_b8b02_row7_col1\" class=\"data row7 col1\" >-11.71%</td>\n                        <td id=\"T_b8b02_row7_col2\" class=\"data row7 col2\" >0.323656</td>\n                        <td id=\"T_b8b02_row7_col3\" class=\"data row7 col3\" >-0.032317</td>\n            </tr>\n            <tr>\n                        <th id=\"T_b8b02_level0_row8\" class=\"row_heading level0 row8\" >8</th>\n                        <td id=\"T_b8b02_row8_col0\" class=\"data row8 col0\" >-0.57%</td>\n                        <td id=\"T_b8b02_row8_col1\" class=\"data row8 col1\" >66.41%</td>\n                        <td id=\"T_b8b02_row8_col2\" class=\"data row8 col2\" >-1.027564</td>\n                        <td id=\"T_b8b02_row8_col3\" class=\"data row8 col3\" >1.295308</td>\n            </tr>\n            <tr>\n                        <th id=\"T_b8b02_level0_row9\" class=\"row_heading level0 row9\" >9</th>\n                        <td id=\"T_b8b02_row9_col0\" class=\"data row9 col0\" >42.81%</td>\n                        <td id=\"T_b8b02_row9_col1\" class=\"data row9 col1\" >-125.78%</td>\n                        <td id=\"T_b8b02_row9_col2\" class=\"data row9 col2\" >-0.884078</td>\n                        <td id=\"T_b8b02_row9_col3\" class=\"data row9 col3\" >0.248043</td>\n            </tr>\n    </tbody></table>"
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.style.format(\"{:.2%}\",subset=['A','B'])\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 5. 标记缺失值\n",
    "- 突出显示缺失值：用符号替代；高亮显示"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "outputs": [
    {
     "data": {
      "text/plain": "          A         B         C         D\n0 -2.453970  0.564621  0.670272 -0.345173\n1 -0.124559  0.081625  0.382049       NaN\n2 -1.367770  0.362711       NaN  0.110784\n3 -1.535637       NaN  2.317123 -0.879901\n4 -1.007252  0.142094 -1.143808  0.918524\n5 -0.552521  1.484423  1.436369  0.382054\n6 -0.216479  1.238049  0.705584 -1.218741\n7 -1.782425 -0.117057  0.323656 -0.032317\n8 -0.005736  0.664067 -1.027564  1.295308\n9  0.428075 -1.257755 -0.884078  0.248043",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>A</th>\n      <th>B</th>\n      <th>C</th>\n      <th>D</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>-2.453970</td>\n      <td>0.564621</td>\n      <td>0.670272</td>\n      <td>-0.345173</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>-0.124559</td>\n      <td>0.081625</td>\n      <td>0.382049</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>-1.367770</td>\n      <td>0.362711</td>\n      <td>NaN</td>\n      <td>0.110784</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>-1.535637</td>\n      <td>NaN</td>\n      <td>2.317123</td>\n      <td>-0.879901</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>-1.007252</td>\n      <td>0.142094</td>\n      <td>-1.143808</td>\n      <td>0.918524</td>\n    </tr>\n    <tr>\n      <th>5</th>\n      <td>-0.552521</td>\n      <td>1.484423</td>\n      <td>1.436369</td>\n      <td>0.382054</td>\n    </tr>\n    <tr>\n      <th>6</th>\n      <td>-0.216479</td>\n      <td>1.238049</td>\n      <td>0.705584</td>\n      <td>-1.218741</td>\n    </tr>\n    <tr>\n      <th>7</th>\n      <td>-1.782425</td>\n      <td>-0.117057</td>\n      <td>0.323656</td>\n      <td>-0.032317</td>\n    </tr>\n    <tr>\n      <th>8</th>\n      <td>-0.005736</td>\n      <td>0.664067</td>\n      <td>-1.027564</td>\n      <td>1.295308</td>\n    </tr>\n    <tr>\n      <th>9</th>\n      <td>0.428075</td>\n      <td>-1.257755</td>\n      <td>-0.884078</td>\n      <td>0.248043</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.iloc[1, 3] = np.nan\n",
    "data.iloc[3, 1] = np.nan\n",
    "data.iloc[2, 2] = np.nan\n",
    "data"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "outputs": [
    {
     "data": {
      "text/plain": "<pandas.io.formats.style.Styler at 0x139c47670>",
      "text/html": "<style  type=\"text/css\" >\n</style><table id=\"T_e68f5_\" ><thead>    <tr>        <th class=\"blank level0\" ></th>        <th class=\"col_heading level0 col0\" >A</th>        <th class=\"col_heading level0 col1\" >B</th>        <th class=\"col_heading level0 col2\" >C</th>        <th class=\"col_heading level0 col3\" >D</th>    </tr></thead><tbody>\n                <tr>\n                        <th id=\"T_e68f5_level0_row0\" class=\"row_heading level0 row0\" >0</th>\n                        <td id=\"T_e68f5_row0_col0\" class=\"data row0 col0\" >-2.453970</td>\n                        <td id=\"T_e68f5_row0_col1\" class=\"data row0 col1\" >0.564621</td>\n                        <td id=\"T_e68f5_row0_col2\" class=\"data row0 col2\" >0.670272</td>\n                        <td id=\"T_e68f5_row0_col3\" class=\"data row0 col3\" >-0.345173</td>\n            </tr>\n            <tr>\n                        <th id=\"T_e68f5_level0_row1\" class=\"row_heading level0 row1\" >1</th>\n                        <td id=\"T_e68f5_row1_col0\" class=\"data row1 col0\" >-0.124559</td>\n                        <td id=\"T_e68f5_row1_col1\" class=\"data row1 col1\" >0.081625</td>\n                        <td id=\"T_e68f5_row1_col2\" class=\"data row1 col2\" >0.382049</td>\n                        <td id=\"T_e68f5_row1_col3\" class=\"data row1 col3\" >-</td>\n            </tr>\n            <tr>\n                        <th id=\"T_e68f5_level0_row2\" class=\"row_heading level0 row2\" >2</th>\n                        <td id=\"T_e68f5_row2_col0\" class=\"data row2 col0\" >-1.367770</td>\n                        <td id=\"T_e68f5_row2_col1\" class=\"data row2 col1\" >0.362711</td>\n                        <td id=\"T_e68f5_row2_col2\" class=\"data row2 col2\" >-</td>\n                        <td id=\"T_e68f5_row2_col3\" class=\"data row2 col3\" >0.110784</td>\n            </tr>\n            <tr>\n                        <th id=\"T_e68f5_level0_row3\" class=\"row_heading level0 row3\" >3</th>\n                        <td id=\"T_e68f5_row3_col0\" class=\"data row3 col0\" >-1.535637</td>\n                        <td id=\"T_e68f5_row3_col1\" class=\"data row3 col1\" >-</td>\n                        <td id=\"T_e68f5_row3_col2\" class=\"data row3 col2\" >2.317123</td>\n                        <td id=\"T_e68f5_row3_col3\" class=\"data row3 col3\" >-0.879901</td>\n            </tr>\n            <tr>\n                        <th id=\"T_e68f5_level0_row4\" class=\"row_heading level0 row4\" >4</th>\n                        <td id=\"T_e68f5_row4_col0\" class=\"data row4 col0\" >-1.007252</td>\n                        <td id=\"T_e68f5_row4_col1\" class=\"data row4 col1\" >0.142094</td>\n                        <td id=\"T_e68f5_row4_col2\" class=\"data row4 col2\" >-1.143808</td>\n                        <td id=\"T_e68f5_row4_col3\" class=\"data row4 col3\" >0.918524</td>\n            </tr>\n            <tr>\n                        <th id=\"T_e68f5_level0_row5\" class=\"row_heading level0 row5\" >5</th>\n                        <td id=\"T_e68f5_row5_col0\" class=\"data row5 col0\" >-0.552521</td>\n                        <td id=\"T_e68f5_row5_col1\" class=\"data row5 col1\" >1.484423</td>\n                        <td id=\"T_e68f5_row5_col2\" class=\"data row5 col2\" >1.436369</td>\n                        <td id=\"T_e68f5_row5_col3\" class=\"data row5 col3\" >0.382054</td>\n            </tr>\n            <tr>\n                        <th id=\"T_e68f5_level0_row6\" class=\"row_heading level0 row6\" >6</th>\n                        <td id=\"T_e68f5_row6_col0\" class=\"data row6 col0\" >-0.216479</td>\n                        <td id=\"T_e68f5_row6_col1\" class=\"data row6 col1\" >1.238049</td>\n                        <td id=\"T_e68f5_row6_col2\" class=\"data row6 col2\" >0.705584</td>\n                        <td id=\"T_e68f5_row6_col3\" class=\"data row6 col3\" >-1.218741</td>\n            </tr>\n            <tr>\n                        <th id=\"T_e68f5_level0_row7\" class=\"row_heading level0 row7\" >7</th>\n                        <td id=\"T_e68f5_row7_col0\" class=\"data row7 col0\" >-1.782425</td>\n                        <td id=\"T_e68f5_row7_col1\" class=\"data row7 col1\" >-0.117057</td>\n                        <td id=\"T_e68f5_row7_col2\" class=\"data row7 col2\" >0.323656</td>\n                        <td id=\"T_e68f5_row7_col3\" class=\"data row7 col3\" >-0.032317</td>\n            </tr>\n            <tr>\n                        <th id=\"T_e68f5_level0_row8\" class=\"row_heading level0 row8\" >8</th>\n                        <td id=\"T_e68f5_row8_col0\" class=\"data row8 col0\" >-0.005736</td>\n                        <td id=\"T_e68f5_row8_col1\" class=\"data row8 col1\" >0.664067</td>\n                        <td id=\"T_e68f5_row8_col2\" class=\"data row8 col2\" >-1.027564</td>\n                        <td id=\"T_e68f5_row8_col3\" class=\"data row8 col3\" >1.295308</td>\n            </tr>\n            <tr>\n                        <th id=\"T_e68f5_level0_row9\" class=\"row_heading level0 row9\" >9</th>\n                        <td id=\"T_e68f5_row9_col0\" class=\"data row9 col0\" >0.428075</td>\n                        <td id=\"T_e68f5_row9_col1\" class=\"data row9 col1\" >-1.257755</td>\n                        <td id=\"T_e68f5_row9_col2\" class=\"data row9 col2\" >-0.884078</td>\n                        <td id=\"T_e68f5_row9_col3\" class=\"data row9 col3\" >0.248043</td>\n            </tr>\n    </tbody></table>"
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 符号替代缺失值\n",
    "data.style.format(None, na_rep=\"-\")"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "outputs": [
    {
     "data": {
      "text/plain": "<pandas.io.formats.style.Styler at 0x139c476a0>",
      "text/html": "<style  type=\"text/css\" >\n#T_f6cd0_row1_col3,#T_f6cd0_row2_col2,#T_f6cd0_row3_col1{\n            background-color:  red;\n        }</style><table id=\"T_f6cd0_\" ><thead>    <tr>        <th class=\"blank level0\" ></th>        <th class=\"col_heading level0 col0\" >A</th>        <th class=\"col_heading level0 col1\" >B</th>        <th class=\"col_heading level0 col2\" >C</th>        <th class=\"col_heading level0 col3\" >D</th>    </tr></thead><tbody>\n                <tr>\n                        <th id=\"T_f6cd0_level0_row0\" class=\"row_heading level0 row0\" >0</th>\n                        <td id=\"T_f6cd0_row0_col0\" class=\"data row0 col0\" >-2.453970</td>\n                        <td id=\"T_f6cd0_row0_col1\" class=\"data row0 col1\" >0.564621</td>\n                        <td id=\"T_f6cd0_row0_col2\" class=\"data row0 col2\" >0.670272</td>\n                        <td id=\"T_f6cd0_row0_col3\" class=\"data row0 col3\" >-0.345173</td>\n            </tr>\n            <tr>\n                        <th id=\"T_f6cd0_level0_row1\" class=\"row_heading level0 row1\" >1</th>\n                        <td id=\"T_f6cd0_row1_col0\" class=\"data row1 col0\" >-0.124559</td>\n                        <td id=\"T_f6cd0_row1_col1\" class=\"data row1 col1\" >0.081625</td>\n                        <td id=\"T_f6cd0_row1_col2\" class=\"data row1 col2\" >0.382049</td>\n                        <td id=\"T_f6cd0_row1_col3\" class=\"data row1 col3\" >nan</td>\n            </tr>\n            <tr>\n                        <th id=\"T_f6cd0_level0_row2\" class=\"row_heading level0 row2\" >2</th>\n                        <td id=\"T_f6cd0_row2_col0\" class=\"data row2 col0\" >-1.367770</td>\n                        <td id=\"T_f6cd0_row2_col1\" class=\"data row2 col1\" >0.362711</td>\n                        <td id=\"T_f6cd0_row2_col2\" class=\"data row2 col2\" >nan</td>\n                        <td id=\"T_f6cd0_row2_col3\" class=\"data row2 col3\" >0.110784</td>\n            </tr>\n            <tr>\n                        <th id=\"T_f6cd0_level0_row3\" class=\"row_heading level0 row3\" >3</th>\n                        <td id=\"T_f6cd0_row3_col0\" class=\"data row3 col0\" >-1.535637</td>\n                        <td id=\"T_f6cd0_row3_col1\" class=\"data row3 col1\" >nan</td>\n                        <td id=\"T_f6cd0_row3_col2\" class=\"data row3 col2\" >2.317123</td>\n                        <td id=\"T_f6cd0_row3_col3\" class=\"data row3 col3\" >-0.879901</td>\n            </tr>\n            <tr>\n                        <th id=\"T_f6cd0_level0_row4\" class=\"row_heading level0 row4\" >4</th>\n                        <td id=\"T_f6cd0_row4_col0\" class=\"data row4 col0\" >-1.007252</td>\n                        <td id=\"T_f6cd0_row4_col1\" class=\"data row4 col1\" >0.142094</td>\n                        <td id=\"T_f6cd0_row4_col2\" class=\"data row4 col2\" >-1.143808</td>\n                        <td id=\"T_f6cd0_row4_col3\" class=\"data row4 col3\" >0.918524</td>\n            </tr>\n            <tr>\n                        <th id=\"T_f6cd0_level0_row5\" class=\"row_heading level0 row5\" >5</th>\n                        <td id=\"T_f6cd0_row5_col0\" class=\"data row5 col0\" >-0.552521</td>\n                        <td id=\"T_f6cd0_row5_col1\" class=\"data row5 col1\" >1.484423</td>\n                        <td id=\"T_f6cd0_row5_col2\" class=\"data row5 col2\" >1.436369</td>\n                        <td id=\"T_f6cd0_row5_col3\" class=\"data row5 col3\" >0.382054</td>\n            </tr>\n            <tr>\n                        <th id=\"T_f6cd0_level0_row6\" class=\"row_heading level0 row6\" >6</th>\n                        <td id=\"T_f6cd0_row6_col0\" class=\"data row6 col0\" >-0.216479</td>\n                        <td id=\"T_f6cd0_row6_col1\" class=\"data row6 col1\" >1.238049</td>\n                        <td id=\"T_f6cd0_row6_col2\" class=\"data row6 col2\" >0.705584</td>\n                        <td id=\"T_f6cd0_row6_col3\" class=\"data row6 col3\" >-1.218741</td>\n            </tr>\n            <tr>\n                        <th id=\"T_f6cd0_level0_row7\" class=\"row_heading level0 row7\" >7</th>\n                        <td id=\"T_f6cd0_row7_col0\" class=\"data row7 col0\" >-1.782425</td>\n                        <td id=\"T_f6cd0_row7_col1\" class=\"data row7 col1\" >-0.117057</td>\n                        <td id=\"T_f6cd0_row7_col2\" class=\"data row7 col2\" >0.323656</td>\n                        <td id=\"T_f6cd0_row7_col3\" class=\"data row7 col3\" >-0.032317</td>\n            </tr>\n            <tr>\n                        <th id=\"T_f6cd0_level0_row8\" class=\"row_heading level0 row8\" >8</th>\n                        <td id=\"T_f6cd0_row8_col0\" class=\"data row8 col0\" >-0.005736</td>\n                        <td id=\"T_f6cd0_row8_col1\" class=\"data row8 col1\" >0.664067</td>\n                        <td id=\"T_f6cd0_row8_col2\" class=\"data row8 col2\" >-1.027564</td>\n                        <td id=\"T_f6cd0_row8_col3\" class=\"data row8 col3\" >1.295308</td>\n            </tr>\n            <tr>\n                        <th id=\"T_f6cd0_level0_row9\" class=\"row_heading level0 row9\" >9</th>\n                        <td id=\"T_f6cd0_row9_col0\" class=\"data row9 col0\" >0.428075</td>\n                        <td id=\"T_f6cd0_row9_col1\" class=\"data row9 col1\" >-1.257755</td>\n                        <td id=\"T_f6cd0_row9_col2\" class=\"data row9 col2\" >-0.884078</td>\n                        <td id=\"T_f6cd0_row9_col3\" class=\"data row9 col3\" >0.248043</td>\n            </tr>\n    </tbody></table>"
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 对缺失值高亮显示\n",
    "data.style.highlight_null(null_color='red')"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 将样式输出到excel\n",
    "- 使用to_excel方法，并用openpyxl作为内核"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "outputs": [],
   "source": [
    "data.style.background_gradient(cmap='viridis',subset=['A', 'B', 'C','D']).\\\n",
    "                              to_excel('style.xlsx', engine='openpyxl')"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}